TEAM_ID=3S5TMAE5S2
TOKEN_KEY_FILE_NAME=/Users/lichongbing/Downloads/lyoggl/src/main/resources/shell/AuthKey_9TPD8SS3C6.p8
AUTH_KEY_ID=9TPD8SS3C6
DEVICE_TOKEN=809eb9bb63e084643ed04de136b251c10b8ded3156b11d85d1735faab6c5b16dbf32d465d39fa830999a61b4d6037c1a30168ed30750dd227aba33daf853370bc668caf7a946ede0af942fa26bf517d0
APNS_HOST_NAME=api.sandbox.push.apple.com
JWT_ISSUE_TIME=$(date +%s)
JWT_HEADER=$(printf '{ "alg": "ES256", "kid": "%s" }' "${AUTH_KEY_ID}" | openssl base64 -e -A | tr -- '+/' '-_' | tr -d =)
JWT_CLAIMS=$(printf '{ "iss": "%s", "iat": %d }' "${TEAM_ID}" "${JWT_ISSUE_TIME}" | openssl base64 -e -A | tr -- '+/' '-_' | tr -d =)
JWT_HEADER_CLAIMS="${JWT_HEADER}.${JWT_CLAIMS}"
JWT_SIGNED_HEADER_CLAIMS=$(printf "${JWT_HEADER_CLAIMS}" | openssl dgst -binary -sha256 -sign "${TOKEN_KEY_FILE_NAME}" | openssl base64 -e -A | tr -- '+/' '-_' | tr -d =)
AUTHENTICATION_TOKEN="${JWT_HEADER}.${JWT_CLAIMS}.${JWT_SIGNED_HEADER_CLAIMS}"
curl -v \
--header "apns-topic:com.lichongbing.timing.push-type.liveactivity" \
--header "apns-push-type: liveactivity" \
--header "authorization: bearer $AUTHENTICATION_TOKEN" \
--data \
'{"aps":{"r":1.0,"b":1.0,"displayname":"测试20220928","g":1.0,"name":"测试20220928","content-state":{"r":1.0,"b":1.0,"g":1.0,"name":"测试","time":"2022-09-28 23:33:34","tag":"测试","plan":300},"id":"99764a101df9475e902f952b673c38f7","event":"update","timestamp":1664379214,"usetime":6327}}' \
--http2 \
https://${APNS_HOST_NAME}/3/device/$DEVICE_TOKEN
